using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

using DataAccess;
using DataTransferObject;

namespace Business
{
    public enum NgonNguBUSResult
    {
        OK,
        MANNERROR,
        TENNNERROR,
        DAOERROR
    }

    public class clsNgonNguBUS
    {
        //Fields.
        private clsNgonNguDAO NgonNguDAO;

        //Constructors.
        public clsNgonNguBUS()
        {
            this.NgonNguDAO = new clsNgonNguDAO();
        }

        #region Methods

        public NgonNguBUSResult KiemTraRong(clsNgonNguDTO obj)
        {
            if (obj.MaNN == "")
                return NgonNguBUSResult.MANNERROR;
            if (obj.TenNN == "")
                return NgonNguBUSResult.TENNNERROR;
            return NgonNguBUSResult.OK;
        }

        public int KTMaNNDeXoa(clsNgonNguDTO obj)
        {
            return this.NgonNguDAO.KiemTraMaNNXoaDuocKhong(obj);
        }

        public DataTable DanhSachNgonNgu()
        {
            return this.NgonNguDAO.SelectAll();
        }

        public NgonNguBUSResult ThemNgonNgu(clsNgonNguDTO obj)
        {
            if (!this.NgonNguDAO.Insert(obj))
                return NgonNguBUSResult.DAOERROR;
            return NgonNguBUSResult.OK;
        }

        public NgonNguBUSResult SuaNgonNgu(clsNgonNguDTO obj)
        {
            if (!this.NgonNguDAO.Update(obj))
                return NgonNguBUSResult.DAOERROR;
            return NgonNguBUSResult.OK;
        }

        public NgonNguBUSResult XoaNgonNgu(clsNgonNguDTO obj)
        {
            if (!this.NgonNguDAO.Delete(obj))
                return NgonNguBUSResult.DAOERROR;
            return NgonNguBUSResult.OK;
        }
        #endregion
    }
}
